<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>会员激活</title>
    <meta content="健康分销" name="keywords" />
    <meta content="健康分销" name="description" />
    <link rel="stylesheet" href="${contextPath}/staticwx/style/weui.css"/>
    <link rel="stylesheet" href="${contextPath}/staticwx/style/weui2.css"/>
    <link rel="stylesheet" href="${contextPath}/staticwx/style/weui3.css"/>
    <link rel="stylesheet" type="text/css" href="${contextPath}/staticwx/drainage/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="${contextPath}/staticwx/drainage/style.css">
    <script type="text/javascript" src="${contextPath}/staticwx/zepto.min.js"></script>
</head>
<body>
<div class="shop-info-list">
    <ul>
        <li><i class="weui_icon_msg weui_icon_warn" style="margin-left:35%;"></i></li>
        <li style="text-align: center;">购买以下任意一款商品即可获得会员资格。<a href="${contextPath}/wx/index.htm">去首页逛逛</a></li>
    </ul>
</div>
<div class="index-box" id="listcar">
    <#list proDraList as product>
    <div class="listcar">
        <a href="javascript:void(0);">
        <div class="carimg"> <img src="${product.smimg!}" width="300" height="230" class="img-responsive lazy"/> </div>
        <div class="carinfo">
            <h4>${product.proname!}</h4>
            <p class="caritem">${product.shortname!}</p>
            <p class="carprice">￥<#if product.price??>${product.price?string("0.00")}<#else>0.00</#if></p>
            <a href="javascript:void(0);" class="combut buyNow" data-pid="${product.id!}">立即购买</a>
        </div>
        </a>
    </div>
    </#list>
</div>
<input type="hidden" id="mid" value="${mid!}"/>
</body>
    <script type="text/javascript">

            $.modal({
                title: "会员激活",
                text: "是否现在激活会员资格?",
                buttons: [
                    { text: "去首页逛逛", className: "default",onClick: function(){location.href='${contextPath}/wx/index.htm'}},
                    { text: "立即激活", onClick: function(){  } },
                ]
            });

        $(".buyNow").on("click",function () {
            var pid=$(this).data("pid");
            var mid=$("#mid").val();
            checkDraPrm(pid,mid);
        })

        function checkDraPrm(pid,mid){
            $.ajax({
                url : '${contextPath}/wx/order/checkDraPrm.htm',
                data : {
                    mid : mid
                },
                type : 'post',
                cache : false,
                dataType : 'json',
                success : function(data) {
                    var json = $.parseJSON(data);
                    if (json.isSuccess == true) {
                        setOrderSession(pid);
                    } else {
                        showMsg(json.errMessage);
                    }
                },
                error : function() {
                    showMsg("异常");
                }
            });
        }

        function setOrderSession(pid){
            $.ajax({
                url : '${contextPath}/wx/order/setOrderSession.htm',
                data : {
                    pid : pid
                },
                type : 'post',
                cache : false,
                dataType : 'json',
                success : function(data) {
                    var json = $.parseJSON(data);
                    if (json.isSuccess == true) {
                        location.href="${contextPath}/wx/order/orderEdit.htm?ot=4"
                    } else {
                        showMsg(json.errMessage);
                    }
                },
                error : function() {
                    showMsg("异常");
                }
            });
        }
    </script>
</html>